#include<bits/stdc++.h>
#include "graph.h"
using namespace std;
const int N=209;
int n,cntnode,cntm;
int cnt[N],ls[N],nc[N];
int b[N][N],id[N][N];
int ans[N],f[N][N];
int dfs(int &u,int dep,int lg){
    int c=Color();
//    cerr<<c<<endl;
    if(c>1){ Move(LastRoad(),c); cntm++; return c; }
    u=++cntnode;
    ls[u]=LastRoad();
    cnt[u]=NumberOfRoads();
    nc[u]=2;
//    cerr<<u<<" "<<cnt[u]<<" "<<ls[u]<<endl;
    int v,re;
    for(int i=1;i<=cnt[u];i++){
        if(i==ls[u]) continue;
        Move(i,nc[u]); cntm++;
        re=dfs(id[u][i],dep+1,lg);
        b[u][i]=re;
        if(re!=1) id[u][i]=0;
    }
    if(u==1) return 1;
    Move(ls[u],3); cntm++; return 1;
}
void solve(int u,int dep,int lg){
    nc[u]=2+((dep>>lg)&1);
    int v,re;
    for(int i=1;i<=cnt[u];i++){
        if(i==ls[u]) continue;
        if(b[u][i]==3) continue;
        if(b[u][i]==1){
            Move(i,nc[u]); cntm++;
            solve(id[u][i],dep+1,lg);
        }
        else{
            Move(i,nc[u]); cntm++;
            int c=Color();
            if(c==3) id[u][i]+=(1<<lg);
            Move(LastRoad(),c); cntm++;
        }
    }
    if(u==1) return;
    Move(ls[u],1); cntm++; return;
}
int sta[N];
void build(int u,int dep){
    f[u][u]=0;
    sta[dep]=u;
    int v;
    for(int i=1;i<=cnt[u];i++){
        if(i==ls[u]) continue;
        if(b[u][i]==1){
            f[u][id[u][i]]=f[id[u][i]][u]=1;
            build(id[u][i],dep+1);
        }
        else if(b[u][i]==2){
            v=sta[id[u][i]];
            f[u][v]=f[v][u]=1;
        }
    }
    return;
}
void Inspect(int R){
//    cerr<<endl<<endl;
    int rt;
    int o=dfs(rt,0,0);
//    cerr<<cntm<<endl;
    n=cntnode;
    for(int i=0;i<=7;i++)
        solve(1,0,i);
    memset(f,0x3f,sizeof(f));
    for(int i=1;i<=n;i++)
        build(1,0);
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
//    cerr<<n<<endl;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            ans[f[i][j]]++;
    for(int i=1;i<=R;i++){
//        cerr<<i<<" "<<ans[i]<<endl;
        Answer(i,ans[i]);
    }
    return;
}